package com.xmkj.bearuser.home.user;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.common.retrofit.bean.HomeReccommedBean;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;
import com.xmkj.bearuser.pk.ContentDetailsActivity;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/7/6
 * 描述：
 */

public class HomeReccommendListAdapter extends CommonAdapter<HomeReccommedBean> {

    public HomeReccommendListAdapter(Context context, List<HomeReccommedBean> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, final HomeReccommedBean item, int position) {
            holder.setText(R.id.tv_title,item.title);
            holder.setText(R.id.tv_descri,item.describe);
            holder.setImageStr(R.id.iv_img,item.pic_url);
            holder.getParentView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, ContentDetailsActivity.class);
                    intent.putExtra(ContentDetailsActivity.ACTIVITY_ID,item.recommend_id+"");
                    intent.putExtra(ContentDetailsActivity.RECOMMENDDETAILS,"RECOMMENDDETAILS");
                    mContext.startActivity(intent);
                }
            });
    }

    @Override
    protected int getItemViewLayoutId(int position, HomeReccommedBean item) {
        return R.layout.item_list_reccommend;
    }
}
